package com.abso.mp3tunes.locker.ui.viewers;

import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.widgets.Composite;

import com.abso.mp3tunes.locker.core.LockerServiceException;
import com.abso.mp3tunes.locker.ui.LockerPlugin;
import com.abso.mp3tunes.locker.ui.jobs.GetTreeRootNodesJob;
import com.abso.mp3tunes.locker.ui.views.LockerBrowserView;

/**
 * A specialized tree viewer showing a list of artists.
 */
public class ArtistViewer extends LockerViewer {

	/**
	 * Constructs a new viewer.
	 * 
	 * @param parent
	 *            the parent control.
	 * @param lockerBrowser
	 *            the Locker browser.
	 */
	public ArtistViewer(Composite parent, LockerBrowserView lockerBrowser) {
		super(parent, lockerBrowser);
		setLabelProvider(new ArtistViewerLabelProvider());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.abso.mp3tunes.locker.ui.views.LockerViewer#doUpdateContent()
	 */
	public void doUpdateContent() {
		Job job = new GetTreeRootNodesJob("Refresh artists", this) {
			protected Object[] doGetRootNodes() throws LockerServiceException {
				return LockerPlugin.getDefault().getLockerService()
						.getArtists();
			}
		};
		job.schedule();
	}

}
